package com.zyc.dao;

import com.zyc.bean.XK;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Controller;

@Controller("XKMage")
public class XKMageImpl implements XKMage{
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public XK selectXK(String number) {
     String  sql = "select * from Xk where number = ?";
        RowMapper<XK> rowMapper = new BeanPropertyRowMapper<>(XK.class);
        XK xk = jdbcTemplate.queryForObject(sql, rowMapper, number);
        return xk;
    }

    @Override
    public  int updateXK(String number, Integer moive) {
        String sql = "update XK set moive =moive + ? where number = ?";
        int i = jdbcTemplate.update(sql, moive);
        return i;
    }
}
